import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import './pages/DesktopApp.dart' as Desktop;
import './pages/lock_screen.dart' as lock_screen;
main(List<String> args) {
  runApp(Basewhidget());
}

class Basewhidget extends StatelessWidget {
  // statelessWidget 是一个无状态的组件，用于自定义组件

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // materialAPP 是作为根组件使用，定义该页面展示的总体布局
      home: Mybody(),
      theme: ThemeData(
        // 主题
          primarySwatch: Colors.blue // 颜色不能是block ，会报错
      ),
    );
  }
}

class Mybody extends StatelessWidget {
  var nows = new DateTime.now().toString();
  int isshow_index = 0;
  var isshow = [Desktop.listv, lock_screen.GetLock];
  @override
  Widget build(BuildContext context) {
//将时间转换成时间戳

    return Scaffold(
      body: Container(
//        color: Colors.yellow,
        decoration: BoxDecoration(
          image: DecorationImage(
//            CachedNetworkImage(imageUrl: 'http://api.btstu.cn/sjbz/?lx=m_dongman&a=1&b=0',fit: BoxFit.cover,)
            // 设置全屏背景图片
            image: NetworkImage(CachedNetworkImage(
              imageUrl: 'http://api.btstu.cn/sjbz/?lx=m_dongman&a=1&b=2',
              fit: BoxFit.cover,).imageUrl),
            fit: BoxFit.cover,
          ),
        ),
        child: Column(
          children: <Widget>[
            Container(
              height: 200,
//              color: Colors.yellow,
              child: this.isshow[this.isshow_index],
            ),
            Spacer(),
            Container(
              height: 50,
//           color: Colors.yellow,
              child: Row(
                children: <Widget>[
                  Expanded(
                    child: Container(),
                  ),
                  Expanded(
                      child: FlatButton(
                        color: Colors.black26,
                        child: Text('锁屏预览',
                          textAlign: TextAlign.start,
                          style: TextStyle(color: Colors.white),
                        ),
                        onPressed: () {
                          print("锁屏预览被点击了");
                        },
                      )
                  ),
                  SizedBox(
                    width: 3,
                    height: 12,
                    child: DecoratedBox(
                      decoration: BoxDecoration(),
                    ),
                  ),

                  Expanded(

                      child: FlatButton(
                        color: Colors.black26,
                        child: new Text('桌面预览', textAlign: TextAlign.left,
                          style: TextStyle(color: Colors.white70),
                        ),

                        onPressed: () {
                          print("桌面预览被点击了");

                        },
                      )

                  ),
                  Expanded(
                    child: Container(),
                  ),
                ],
              ),
            ),
            Container(
              height: 70,
//              color: Colors.blueAccent,

              child: Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: Container(),
                  ),

                  Expanded(
                      flex: 3,
                      child: FlatButton(
                        color: Colors.black26,
                        child: Text('设置为锁屏壁纸',
                          textAlign: TextAlign.start,
                          style: TextStyle(color: Colors.white),
                        ),
                        onPressed: () {
                          print("锁屏预览被点击了");
                        },
                      )
                  ),
                  SizedBox(
                    width: 40,
                    height: 12,
                    child: DecoratedBox(
                      decoration: BoxDecoration(),
                    ),
                  ),
                  Expanded(
                      flex: 3,
                      child: FlatButton(
                        color: Colors.black26,
                        child: new Text('设置为桌面壁纸', textAlign: TextAlign.left,
                          style: TextStyle(color: Colors.white70),
                        ),

                        onPressed: () {
                          print("桌面预览被点击了");
                        },
                      )

                  ),
                  SizedBox(
                    width: 40,
                    height: 12,
                    child: DecoratedBox(
                      decoration: BoxDecoration(),
                    ),
                  ),
                ],
              ),

            )
          ],
        ),
      ),
    );
  }
}